package two_shang.otherTest.ThreadPackage;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TestStop implements Runnable {

    private boolean flag = true;

    @Override
    public void run() {
        int i = 0;
        while (flag) {
            System.out.println("run.....Thread" + i++);
        }
    }

    public void stop() {
        this.flag = !flag;
    }

    public static void tenDown() throws InterruptedException {
        Date date = new Date(System.currentTimeMillis());
        System.out.println(date);
        int num = 10;
        while ((num--) != 0) {
            Thread.sleep(1000);
            System.out.println(new SimpleDateFormat("HH:mm:ss").format(date));
            date = new Date(System.currentTimeMillis());
        }
    }
}
